<template>
	<view>
		<u-form>
			<!-- <u-field type="textarea" v-model="content" label-width="0" :clearable="false" placeholder="请输入投诉内容" /> -->
			<textarea 
			style="width: 100%; padding: 20rpx 30rpx; box-sizing: border-box;" 
			@input="handleInput" 
			:value="content" 
			placeholder="请输入投诉内容" />
			<view style="margin: 32rpx;">
				<u-button shape="circle" type="primary" @click="onSubmit">
					提交
				</u-button>
			</view>
		</u-form>
		<u-top-tips ref="uTips"></u-top-tips>
		<u-toast ref="uToast" />
	</view>
</template>

<script>
	import http from '@/utils/http'
	import api from '@/api'
	export default {
		name: 'CustomerServiceComplaint',
		props: ['cs_id'],
		data() {
			return {
				content: '',
				content2:''
			}
		},
		methods: {
			initContent() {
				this.content = ''
			},
			handleInput(e){
				this.content2 = e.detail.value
			},
			onSubmit() {
				this.content = this.content2
				let params = {
					cs_id: this.cs_id,
					content: this.content
				}
				if (this.content == '') {
					this.$refs.uToast.show({
						title: '请填写投诉内容'
					})
					return false
				}
				http
					.post(api.customer_service_complaint, params)
					.then(res => {
						this.$refs.uTips.show({
							title: '投诉成功，我们会尽快处理',
							type: 'success'
						})
						setTimeout(() => {
							uni.navigateBack({
								delta:1
							})
							this.content = ''
							this.content2 = ''
						}, 2000)
					})
					.catch(() => {})
			}
		}
	}
</script>

<style lang="scss" scoped></style>
